package ModelLayer;

import java.util.Date;
import java.util.LinkedList;

public class RoomBooking {
	private static double halfRate = 0.5;
	private static double quaterRate = 0.25;
	private static int halfDepositRefundDays = 14;
	private static int quaterDepositRefundDays = 7;
	private int id;
	private Date createDate;
	private Date startDate;
	private Date endDate;
	private double deposit;
	private double rent;
	private KeyWord payStatus;
	private LinkedList<RoomBookingLine> lines;

	public RoomBooking() {
		super();
		rent = 0;
	}

	public RoomBooking(int roomBookingId) {
		id = roomBookingId;
		rent = 0;
	}

	public void getRentWithoutDiscount() {
		double price = 0;
		for (RoomBookingLine rbl : lines) {
			price += rbl.getQuantity() * rbl.getRoomType().getPricePerNight();
		}
		setRent(price * getNurOfNights());
	}

	public int getNurOfNights() {
		int nights = (int) ((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));
		return nights;
	}

	public static double getHalfRate() {
		return halfRate;
	}

	public static void setHalfRate(double halfRate) {
		RoomBooking.halfRate = halfRate;
	}

	public static double getQuaterRate() {
		return quaterRate;
	}

	public static void setQuaterRate(double quaterRate) {
		RoomBooking.quaterRate = quaterRate;
	}

	public int getId() {
		return id;
	}

	public void setId(int roomBookingId) {
		id = roomBookingId;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public double getDeposit() {
		return deposit;
	}

	public void setDeposit(double deposit) {
		this.deposit = deposit;
	}

	public double getRent() {
		return rent;
	}

	public void setRent(double rent) {
		this.rent = rent;
	}

	public KeyWord getPayStatus() {
		return payStatus;
	}

	public void setPayStatus(KeyWord payStatus) {
		this.payStatus = payStatus;
	}

	public LinkedList<RoomBookingLine> getLines() {
		return lines;
	}

	public void setLines(LinkedList<RoomBookingLine> lines) {
		this.lines = lines;
	}

	public static int getHalfDepositRefundDays() {
		return halfDepositRefundDays;
	}

	public static void setHalfDepositRefundDays(int halfDepositRefundDays) {
		RoomBooking.halfDepositRefundDays = halfDepositRefundDays;
	}

	public static int getQuaterDepositRefundDays() {
		return quaterDepositRefundDays;
	}

	public static void setQuaterDepositRefundDays(int quaterDepositRefundDays) {
		RoomBooking.quaterDepositRefundDays = quaterDepositRefundDays;
	}

}